﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ServiceLibrary.Model;
using System.Data.SqlClient;

namespace ServiceLibrary.DLayer
{
    public class Z_SISM_Soap_Log
    {
        public void Execute(string guid, string envelopeIN, string endPoint)
        {
            SqlParameter[] param_Z_SISM_Soap_Log = new SqlParameter[4];

            param_Z_SISM_Soap_Log[0] = new SqlParameter("DATA_INVIO", System.Data.SqlDbType.DateTime);
            param_Z_SISM_Soap_Log[0].Value = DateTime.Now;

            param_Z_SISM_Soap_Log[1] = new SqlParameter("GUID", System.Data.SqlDbType.NVarChar, 200);
            param_Z_SISM_Soap_Log[1].Value = guid;

            param_Z_SISM_Soap_Log[2] = new SqlParameter("SOAP", System.Data.SqlDbType.NText);
            param_Z_SISM_Soap_Log[2].Value = envelopeIN;

            param_Z_SISM_Soap_Log[3] = new SqlParameter("ENDPOINT", System.Data.SqlDbType.NVarChar, 50);
            param_Z_SISM_Soap_Log[3].Value = endPoint;

            BABELE_Entities context = new BABELE_Entities();

            var getEsito = SqlHelper.ExecuteStoredProcedure<string>(context, "Z_SISM_Soap_Log", param_Z_SISM_Soap_Log);

            if (getEsito.ToString().Equals("0"))
                throw new Exception("Trace del messaggio SOAP non riuscita: StoredProcedure - Z_SISM_Soap_Log");

        }

    }
}
